<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>04计算属性简写</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{title}}</h1>
    姓：<input type="text" v-model="firstName">
    <br>
    名：<input type="text" v-model="lastName">
    <br>
    全名：<span>{{fullName}}</span>
  </div>
  <script>
    const vm = new Vue({
      el: '#app',
      data() {
        return {
          title: '计算属性简写',
          firstName: 'zhang',
          lastName: 'san'
        }
      },
      // 只读取，无需修改时，计算属性才可以简写
      computed: {
        fullName() {
          return this.firstName + '-' + this.lastName
        }
      }
    })
  </script>
</body>
</html>